.\"	$NetBSD$
.\"
.\" Copyright (c) 2023 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Thomas Klausner.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd July 12, 2023
.Dt CVS2HG 1
.Os
.Sh NAME
.Nm cvs2hg
.Nd convert CVS repository to Mercurial
.Sh SYNOPSIS
.Nm
.Op Fl a Ar authormap
.Op Fl b Ar brachmap
.Op Fl f Ar fixup-sql-script
.Op Fl s Ar merge-limit-seconds
.Ar source
.Ar destination
.Sh DESCRIPTION
.Nm
is a script to convert a
.Xr cvs 1
repository to
.Xr hg 1
using
.Xr cvs2fossil 1
and
.Xr hg 1 .
.Pp
.Ar source
must be a CVS repository (the server side, i.e. the RCS files, not a
checkout).
.Nm
will create
.Ar destination Ns Pa .fossil
(the fossil conversion created by
.Xr cvs2fossil 1 ) .
.Xr fossil 1
will create a
.Xr git 1
fast-import file
.Ar destination Ns Pa .fossil.export
which will be converted into the Mercurial repository
.Ar destination Ns Pa .hg
by
.Xr hg 1.
.Xr hg 1
will also be used to update the author information using an authormap
file, if provided.
.Pp
.Nm
supports the following flags:
.Bl -tag -width 10n
.It Fl a Ar authormap
Pass a
.Xr hg 1
authormap file for creating proper author information using
.Xr hg 1 Cm convert .
The file should consist of lines of the format:
.Dl login=Full Name <email@address>
.It Fl b Ar branchmap
Pass a
.Xr hg 1
branchmap file for renaming branches using
.Xr hg 1 Cm convert .
The file should consist of lines of the format:
.Dl old_branch_name new_branch_name
.It Fl f Ar fixup-sql-script
Pass an SQL fixup script for
.Xr cvs2fossil 1
for its
.Fl f
flag.
.It Fl s Ar merge-limit-seconds
Pass a merge time limit in seconds to
.Xr cvs2fossil 1 .
.El
.Sh EXAMPLES
To convert the
.Nx
src repository, if you have developer access, do:
.Bd -literal -offset indent
export REPO=src
export LOGIN=username
rsync -aS --delete -e ssh "$LOGIN"@cvs.NetBSD.org::cvsroot/"$REPO" "$REPO"-rsync
cvs2hg -a authormap -b branchmap -s 300 "$REPO"-rsync/"$REPO" "$REPO"
.Ed
.Pp
The conversion output is in
.Pa src.hg .
The intermediate fossil directory is
.Pa src.fossil
and the corresponsing fast-import file
.Pa src.fossil.export .
If you use
.Fl a
there will be another
.Pa src.hg.old
directory, respectively.
You can delete them after the conversion.
